import java.util.Scanner;
import java.util.Arrays;

public class Anagram {
	 public static void main(String args[]) {
		Scanner reader = new Scanner(System.in).useDelimiter("\\n");
		System.out.println("Enter the first string:");
		String string1 = reader.next();
		System.out.println("Enter the second string:");
		String string2 = reader.next();
		char[] charArray1 = string1.replaceAll("\\s","").toLowerCase().toCharArray();
		char[] charArray2 = string2.replaceAll("\\s","").toLowerCase().toCharArray();
		Arrays.sort(charArray1);
		Arrays.sort(charArray2);
		if (charArray1.length != charArray2.length) {
			System.out.println("The character counts in the entered strings are not equal.\n Strings are not anagrams.");
			return;
		}
		for (int iterator = 0; iterator < charArray1.length; iterator++) {
			if (charArray1[iterator] != charArray2[iterator]) {
				System.out.println("Strings are not anagrams.");
				return;
			}	
		}
		// if this point was reached, then these strings are anagrams
		System.out.println("Strings are anagrams.");
	}
}